package cn.edu.nuc.crm.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.nuc.crm.dao.AdminMapper;
import cn.edu.nuc.crm.entity.Admin;
import cn.edu.nuc.crm.service.interfaces.AdminService;

@Service
public class AdminServiceImpl implements AdminService {
	@Autowired
	private  AdminMapper adminMapper;
	@Override
    public Admin login(String adminnane, String adminpassword) {
		
		Admin admin = adminMapper.findByAdmin(adminnane);
		System.out.println(admin);
		if( admin == null){
			throw new RuntimeException("用户名错误");
		}else if( !adminpassword.equals(admin.getAdminpassword())){
			throw new RuntimeException("密码错误");
		}
		return admin;
	}
}
